package main;

import java.awt.*;

public class Player extends Item {
    public static String url1="src/resources/路飞正面照片.png",url2="src/resources/路飞背面照片.png",url3="src/resources/路飞左面照片.png",url4="src/resources/路飞右面照片.png";
    protected Integer hp=10,atk=10,dfc=10,money=10;
    protected Label pic;
//    返回可否击败，可以便获取战利品
    public int attack(Item enemy,boolean sit){
        if(atk<=enemy.dfc){
            return -1;
        }
        int dt=((enemy.hp+atk-enemy.dfc-1)/(atk-enemy.dfc)-1)*(enemy.atk-dfc<0?0:enemy.atk-dfc);
        if(sit&&dt<hp){
            hp-=dt;
            money+=enemy.money;
        }
        return hp-dt;
    }
    public void move(int dir, Container c){
        int nx=x,ny=y;
        switch (dir){
            case 0:nx--;break;
            case 1:ny++;break;
            case 2:nx++;break;
            case 3:ny--;break;
        }
        String tp=Main.map.mp[nx][ny].type;
        if(tp!="Wall"){
            if(tp=="Floor"){
                Main.infoBar.showInfo(null,nx,ny,c);
                x=nx;
                y=ny;
                pic.setBounds(pic.width*y,pic.height*x,pic.width,pic.height);
            }
            else{
                Main.infoBar.showInfo(Main.map.mp[nx][ny],nx,ny,c);
                System.out.println("在:"+nx+"  "+ny+"是："+tp);
            }
        }
        else{
            Main.infoBar.showInfo(null,nx,ny,c);
        }

    }
    public Player(int x,int y){
        this.x=x;
        this.y=y;
        this.type="Player";
        pic=new Label(url1,1,1);
    }
}
